//
//  CellOfWater.m
//  HYHOME
//
//  Created by Mac on 16/1/27.
//  Copyright © 2016年 Mac. All rights reserved.
//

#import "CellOfWater.h"
#import "ModelOfWater.h"
#import "UIImageView+WebCache.h"
#import "DKNightVersion.h"
@implementation CellOfWater

- (void)dealloc{

    [_imageV release];
    [_labeloftitle release];
    [super dealloc];

}

- (instancetype)initWithFrame:(CGRect)frame{

    self = [super initWithFrame:frame];
    if (self) {
        
        self.labeloftitle = [[UILabel alloc]init];
        [self.contentView addSubview:self.labeloftitle];
        
        
        self.imageV = [[UIImageView alloc]init];
        [self.contentView addSubview:self.imageV];
        
     
        
        [self.labeloftitle release];
        [self.imageV release];
        
        
    }

    return self;


}

+ (CGFloat)height:(UIImage *)imageT{
    
    CGFloat scale = imageT.size.height / imageT.size.width;
    
    
    return scale * (([UIScreen mainScreen].bounds.size.width - 30) / 2);
}


- (void)layoutSubviews{
    
    [super layoutSubviews];
    
    self.imageV.frame = CGRectMake(0, 0, self.bounds.size.width, [self.class height:self.imageV.image]);
    
 
    self.imageV.layer.shadowOffset = CGSizeMake(0, 1);
    self.imageV.layer.shadowOpacity = 1;
    
    self.imageV.layer.cornerRadius = 5;
    self.imageV.layer.masksToBounds = YES;

    self.labeloftitle.frame = CGRectMake(0, self.imageV.frame.size.height, self.bounds.size.width, 60);
    self.labeloftitle.numberOfLines = 2;
    self.labeloftitle.font = [UIFont boldSystemFontOfSize:15];
    self.labeloftitle.textAlignment = NSTextAlignmentCenter;
    
    self.labeloftitle.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor lightGrayColor]);

    
}



- (void)passModel:(ModelOfWater *)model{
    
    [self.imageV sd_setImageWithURL:[NSURL URLWithString:model.fliename] placeholderImage:[UIImage imageNamed:@"jz"]];
    self.labeloftitle.text = model.title;
    
    

}



@end
